<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #demo{
       width: 800px;
       height: 600px;
        border: 1px solid #000;
    }
</style>
<body>
    <canvas id="demo"></canvas>

    <script>
        //获取画布
        let canvas = document.getElementById('demo')
        //获取画笔 ，绘制上下文
        let context = canvas.getContext('2d')
        const img = new Image()
        img.src = 'https://ps.ssl.qhimg.com/sdmt/386_266_100/t044a14840623f02465.webp'
        img.onload = function(){
            context.drawImage(img,0,0,canvas.width,canvas.height)
        }

    </script>
</body>
</html>